v f r . p y 
 
 = = = = = = 
 
 
 
 I n s p i r e d   o n :   D a i z ' s   A u t o M K V C h a p t e r s ,   T h e F l u f f ' s   s p l i t _ a u d ,   B D _ C h a p t e r s 
 
 
 
 N e e d s :   P y t h o n   3 ;   M k v T o o l N i x   ( f o r   a u d i o   t r i m m i n g ) 
 
 
 
 W h a t   i t   d o e s 
 
 - - - - - - - - - - - - 
 
 
 
 *   R e a d s   t h e   f i r s t   l i n e   o f   u n c o m m e n t e d   T r i m s   f r o m   a n   . a v s ; 
 
 *   U s e s   t i m e c o d e s   f i l e s   t o   g e t   e a c h   t r i m ' s   f r a m e ' s   t i m e s t a m p ; 
 
 *   O f f s e t s   t h e   t r i m s   a c c o r d i n g l y ; 
 
 *   C r e a t e s   a   b a s i c   x m l   w i t h   M a t r o s k a   c h a p t e r s ,   x 2 6 4   c h a p t e r s   i f   e n d i n g   i n   ' x 2 6 4 . t x t '   o r   O G M   c h a p t e r s   i f   a n y   o t h e r   e x t e n s i o n   i s   u s e d ; 
 
 *   C r e a t e s   a   q p f i l e   t o   u s e   w i t h   x 2 6 4 ; 
 
 *   C u t s   a n d   m e r g e s   a u d i o   ( a s   p e r   s p l i t _ a u d ,   o n l y   u s i n g   v 2   t i m e c o d e s   i n s t e a d   o f   e x p e c t i n g   c f r )   ( a l l   o p t i o n s   w o r k   a s   s p l i t _ a u d ) ; 
 
 *   N o   l o n g e r   n e e d s   t c C o n v   b u t   c o n v e r t s   v 1   t i m e c o d e s   t o   v 2   i n t e r n a l l y ; 
 
 *   I f   r e q u e s t e d ,   c a n   o u t p u t   v 2   t i m e c o d e s   f r o m   v 1   a n d   f p s   p a r s i n g .   I f   - - o f p s   i s   b e i n g   u s e d ,   v 2   t i m e c o d e s   w i l l   u s e   i t ; 
 
 *   C a n   o u t p u t   a   q p f i l e   w i t h   c o n v e r t e d   f r a m e s   m e a n t   t o   b e   u s e d   f o r   a n   i v t c ' d   e n c o d e   u s i n g   n o n - i v t c ' d   f r a m e s   ( f e a t u r e   i n s p i r e d   b y   a u t o m k v c h a p t e r s )   ( n o t   c o m p l e t e l y   a c c u r a t e ,   o b v i o u s l y ) ; 
 
 *   U s i n g   F F m p e g s o u r c e ' s   C o r r e c t N T S C R a t i o n a l F r a m e r a t e ,   t h i s   i s   a c t u a l l y   m o r e   p r e c i s e   i n   t h e   v 2   t i m e c o d e s   i t   p r o d u c e s   t h a n   t c C o n v ; 
 
 *   A c c e p t s   A u t o M K V C h a p t e r s - l i k e   t e m p l a t e s . 
 
 
 
 O n l y   t h e   . a v s   w i t h   t r i m s   i s   r e q u i r e d   f o r   v f r . p y   t o   r u n .   Y o u   c a n   u s e   - v   a n d / o r   - - t e s t   t o   d e b u g   t h e   s c r i p t .   A l l   o t h e r   o p t i o n s   a n d   a r g u m e n t s   a r e   o p t i o n a l . 
 
 
 
 U s a g e 
 
 - - - - - 
 
 
 
 v f r . p y   - i   a u d i o . a a c   - o   a u d i o . c u t . m k a   - f   3 0 / 1 . 0 0 1   - l   t R i m   - c   c h a p t e r s . x m l   - t   t e m p l a t e . t x t   \ 
 
 - n   c h n a m e s . t x t   - q   q p f i l e . q p f   - v m r   - - o f p s   2 4 / 1 . 0 0 1   - - t i m e c o d e s   v 2 . t x t   - - t e s t   t r i m s . a v s   o u t t r i m s . a v s 
 
 
 
 R e q u i r e d : 
 
 t r i m s . a v s   =   G e t s   f i r s t   u n c o m m e n t e d   l i n e   s t a r t i n g   w i t h   t r i m s   f r o m   t h i s   A v i s y n t h   s c r i p t 
 
 
 
 O p t i o n a l : 
 
 - i   =   A u d i o   t o   b e   c u t   ( t a k e s   w h a t e v e r   m k v m e r g e   t a k e s ) 
 
 - o   =   C u t   a u d i o   i n s i d e   . m k a 
 
           D e f a u l t :   i n p u t . c u t . m k a 
 
 - d   =   M a n u a l l y   s e t   d e l a y   t i m e   f o r   i n p u t   a u d i o   ( c a n   b e   n e g a t i v e ) 
 
 - b   =   R e v e r s e   p a r s i n g   o f   . a v s   ( f r o m   b o t t o m   t o   t o p ) 
 
 - f   =   F r a m e s   p e r   s e c o n d   o r   t i m e c o d e s   f i l e   i f   v f r   i n p u t 
 
           ( t a k e s   " 2 5 " ,   " 2 4 0 0 0 / 1 0 0 1 " ,   " 3 0 0 0 0 : 1 0 0 1 " ,   " 2 4 / 1 . 0 0 1 "   a n d   " 3 0 : 1 . 0 0 1 "   a s   c f r   i n p u t ) 
 
           D e f a u l t :   3 0 0 0 0 / 1 0 0 1 
 
 - l   =   L o o k   f o r   a   l i n e   s t a r t i n g   w i t h   a   c a s e - s e n s i t i v e   t r i m ( )   o r   c a s e - i n s e n s i t i v e   c o m m e n t   s u c c e e d i n g   t h e   t r i m s ,   i n t e r p r e t e d   a s   a   r e g u l a r   e x p r e s s i o n . 
 
           D e f a u l t :   c a s e   i n s e n s i t i v e   t r i m 
 
 - g   =   S p e c i f y   d i r e c t l y   t h e   l i n e   u s e d 
 
 - c   =   C h a p t e r s   f i l e .   I f   e x t e n s i o n   i s   ' x m l ' ,   o u t p u t s   M K V   C h a p t e r s ; 
 
           i f   e x t e n s i o n   i s   ' x 2 6 4 . t x t ' ,   o u t p u t s   x 2 6 4   C h a p t e r s ;   e l s e ,   o u t p u t s   O G M   C h a p t e r s 
 
 - n   =   T e x t   f i l e   w i t h   c h a p t e r   n a m e s ,   o n e   p e r   l i n e ;   a s s u m e d   t o   b e   U T F - 8   w i t h o u t   B O M 
 
 - q   =   Q P F i l e   f o r   u s e   i n   x 2 6 4 ;   w i l l   u s e   - - o f p s   f r a m e s 
 
 - t   =   T e m p l a t e   f i l e   f o r   a d v a n c e d   M a t r o s k a   c h a p t e r s 
 
 - v   =   V e r b o s e   m o d e 
 
 - m   =   M e r g e   s p l i t   a u d i o   f i l e s 
 
 - r   =   R e m o v e   s p l i t   a u d i o   f i l e s   a f t e r   m e r g i n g 
 
 - - u i d   =   S e t   b a s e   U I D   f o r   - - t e m p l a t e / - - c h n a m e s 
 
 - - c h n a m e s   =   P a t h   t o   b a s i c   t e x t   c o n t a i n i n g   c h a p t e r   t i t l e s   s e p a r a t e d   b y   n e w l i n e s 
 
 - - o f p s   =   O u t p u t   F P S   ( u s e d   i n   q p f i l e ,   v 2   t i m e c o d e s   a n d   a v s   e x p o r t ) 
 
                   D e f a u l t :   - f 
 
 - - t i m e c o d e s   =   O u t p u t   v 2   t i m e c o d e s   ( f r o m   f p s   a n d   v 1   p a r s i n g )   ( i f   u s i n g   - - o f p s ,   o u t p u t s   v 2   t i m e c o d e s   u s i n g   t h i s ) 
 
 - - s b r   =   S e t   t h i s   i f   i n p u t t i n g   a n   . a a c   a n d   i t ' s   S B R / H E - A A C 
 
 - - t e s t   =   T e s t   M o d e   ( d o e s n ' t   c r e a t e   n e w   f i l e s ) 
 
 o u t t r i m s . a v s   =   I f   c h a p p a r s e . p y   i s   p r e s e n t ,   o u t p u t s   . a v s   w i t h   o f f s e t   a n d   c o n v e r t e d   t r i m s 
 
 
 
 T o   d o : 
 
 *   O p t i m i z e   c o d e   a n d / o r   i m p r o v e   i t s   l e g i b i l i t y 
 
 
 
 K n o w n   i s s u e s : 
 
 *   C o n v e r s i o n   f r o m   a   d i f f e r e n t   i n p u t   f p s   t o   o u t p u t   f p s   i s   n o t   a c c u r a t e   ( p r o b a b l y   n o   w a y   i t   c a n   e v e r   b e   f i x e d ) 